#include "static_reflect.h"
#include <cassert>
#include <string>
#include <iostream>
#ifdef _WIN32
    #include <windows.h>
#endif // _WIN32

struct A
{
};

struct Point
{
    double x;
    int y;
    char str[100];
    std::string str1;
    int array[10];
};

struct Rect
{
    Point point1;
    uint32_t color;
    std::string str;
};

REGISTER_STRUCT(Point, (x1)x, (y)y, (str)str, (array)array, (strzz)str1);

REGISTER_STRUCT(Rect, (Point1)point1, (color)color, (str)str);

std::ostream &operator<<(std::ostream &output, const Point &)
{
    return output;
}

template <typename T>
void PrintFields(T &obj)
{
    StaticReflect::ForEach(obj, [](const char* field_name, auto &&field_value) {
        if (StaticReflect::IsReflected<typename std::remove_reference<decltype(field_value)>::type>)
        {
            std::cout << "field_name: " << field_name << " IsReflected" << '\n';
            PrintFields(field_value);
        }
        else
        {
            std::cout << "field_name: " << field_name << " field_value: " << field_value << '\n';
        }
    });
}

int main()
{
#ifdef _WIN32
    SetConsoleCP(65001);
    SetConsoleOutputCP(65001);
#endif // _WIN32
    const Point point {1.1, 10, "fdfdfdfd", "gffgf", {1, 2, 3, 4}};
    Rect ret {point, 100, "fdghghggh"};
    assert(StaticReflect::IsReflected<Point> == true);
    assert(StaticReflect::IsReflected<A> == false);
    PrintFields(ret);
    return 0;
}